home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / emacs-18.59src.lha / emacs-18.59 / amiga / contrib / lindgren / sas-c-emacs.lha / sc_emacs.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1993-06-19  |  1.9 KB  |  103 lines

  1. /*
  2.  *  FILE
  3.  *    sc_emacs.rexx
  4.  *
  5.  *  DESCRIPTION
  6.  *    Simple handler between GNUEmacs and SCMSG.
  7.  *
  8.  *    This program is used when SCMSG calls emacs. (When EMACS
  9.  *    asks SCMSG for information it can do it directly.)
  10.  *
  11.  *  AUTHOR
  12.  *    Anders Lindgren, d91ali@csd.uu.se
  13.  */
  14.  
  15. trace ?r
  16.  
  17. if ~Show('L','rexxsupport.library') then do
  18.         if ~AddLib('rexxsupport.library',0,-30,0) then do
  19.                 say 'Unable to open rexxsupport.library'
  20.                 exit 20
  21.         end
  22.     end
  23.  
  24. if ~Show('L','slashquote.library') then do
  25.         if ~AddLib('slashquote.library',0,-30,0) then do
  26.                 say 'Unable to open slashquote.library'
  27.                 exit 20
  28.         end
  29.     end
  30.  
  31.  
  32. port = 'SC_EMACS'
  33. if ~OpenPort(port) then do
  34.         say 'Error while opening port' port
  35.         exit 20
  36.     end
  37.  
  38. /* Start emacs if it's not already running */
  39. if show('p', 'EMACS1') = 0 then do
  40.     address command 'emacs'
  41.     delay(1100)
  42.     end
  43.  
  44. quit=0
  45.  
  46. do until quit
  47.         call WaitPkt(port)
  48.         pkt = GetPkt(port)
  49.         if pkt = Null() then do
  50.                 iterate
  51.         end
  52.  
  53.         msg = zerot2str(pkt,0)   /* getarg(pkt, 0)  */  
  54.  
  55.     parse VALUE msg WITH cmd line 'a'x errnum 'a'x,
  56.         class 'a'x file 'a'x text
  57.  
  58.     retcode = 20
  59.  
  60.     select
  61.         when cmd = 'QUIT' then do
  62.             retcode = 0
  63.             quit = 1
  64.             end
  65.  
  66.         when cmd = 'GOTOLINE' then do
  67.             retcode = 0
  68.             end
  69.  
  70.         when cmd = 'GOTOFILE' then do
  71.             
  72.             /*
  73.              * Undocumented feature: SCMSG quotes filenames
  74.              * and texts which contains spaces. VERY STUPID!
  75.              * How can a call be made to emacs without
  76.              * extensive parsing?
  77.              */
  78.  
  79.             if words(file) > 1 then do
  80.                 file=substr(file,2,length(file)-2)
  81.                 end
  82.             
  83.             if words(text) > 1 then do
  84.                 text=substr(text,2,length(text)-2)
  85.                 end
  86.             
  87.             msg = '(sas-c-view-message ',
  88.                 slashquote(file) line slashquote(text),
  89.                     slashquote(class) errnum')'
  90.             /* call writeln(stderr, msg) */
  91.             address 'EMACS1' msg
  92.             retcode = 0
  93.             end
  94.  
  95.         otherwise nop
  96.         end
  97.  
  98.     call Reply(pkt,retcode)
  99.             
  100.     end
  101.     
  102. ClosePort(port)
  103.